package com.hr.User.service.impl;

import com.hr.User.entity.UserTable;
import com.hr.User.mapper.UserMapper;
import com.hr.User.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
/**
 * @author DSL
 * @create 2024-10-31 9:47
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public UserTable selectByPhone(String phone) {
        System.out.println("dsd"+phone);
            return userMapper.getUserByPhone(phone);
    }
    @Override
    public int insertUser(UserTable userTable) {
        LocalDateTime now = LocalDateTime.now();//获取当前时间
        userTable.setCreatedDate(now);
        int number = userMapper.addUser(userTable);
        System.out.println(now);
         return number;
    }
    @Override
    public int alterUser(UserTable userTable) {
        LocalDateTime now = LocalDateTime.now();
        userTable.setUpdatedDate(now);
        System.out.println(now);
        int number = userMapper.updateUser(userTable);
        return number;
    }
    @Override
    public int removeUser(UserTable userTable) {
        int number = userMapper.deleteUser(userTable.getPhone());
        return number;
    }
}
